<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="计算机," />





  <link rel="alternate" href="/atom.xml" title="学不可以已" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/uploads/favicon.ico?v=5.1.2" />






<meta name="description" content="什么是YUMYUM（全称为 Yellow dog Updater, Modified）是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理，能够从指定的服务器自动下载RPM包并且安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，无须繁琐地一次次下载、安装。 YUM的作用 Typ在Linux上使用源码的方式安装软件非常满分，使用yum可以简化安">
<meta name="keywords" content="计算机">
<meta property="og:type" content="article">
<meta property="og:title" content="制作本地yum">
<meta property="og:url" content="http://eregg.com/2016/11/22/制作本地yum/index.html">
<meta property="og:site_name" content="学不可以已">
<meta property="og:description" content="什么是YUMYUM（全称为 Yellow dog Updater, Modified）是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理，能够从指定的服务器自动下载RPM包并且安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，无须繁琐地一次次下载、安装。 YUM的作用 Typ在Linux上使用源码的方式安装软件非常满分，使用yum可以简化安">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://123.57.181.198/images/linux/localyum1.jpg">
<meta property="og:image" content="http://123.57.181.198/images/linux/localyum.jpg">
<meta property="og:updated_time" content="2017-09-21T18:14:58.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="制作本地yum">
<meta name="twitter:description" content="什么是YUMYUM（全称为 Yellow dog Updater, Modified）是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理，能够从指定的服务器自动下载RPM包并且安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，无须繁琐地一次次下载、安装。 YUM的作用 Typ在Linux上使用源码的方式安装软件非常满分，使用yum可以简化安">
<meta name="twitter:image" content="http://123.57.181.198/images/linux/localyum1.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://eregg.com/2016/11/22/制作本地yum/"/>





  <title>制作本地yum | 学不可以已</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?5f1629a8f7280df347a90a49b56b2b49";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">学不可以已</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">青，取之于蓝，而青于蓝</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://eregg.com/2016/11/22/制作本地yum/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="eregg">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学不可以已">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">制作本地yum</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-22T09:38:47+08:00">
                2016-11-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="什么是YUM"><a href="#什么是YUM" class="headerlink" title="什么是YUM"></a><a href="#什么是YUM" title="什么是YUM"></a>什么是YUM</h3><p>YUM（全称为 Yellow dog Updater, Modified）是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理，能够从指定的服务器自动下载RPM包并且安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，无须繁琐地一次次下载、安装。</p>
<h3 id="YUM的作用"><a href="#YUM的作用" class="headerlink" title="YUM的作用"></a><a href="#YUM的作用" title="YUM的作用"></a>YUM的作用</h3><ul>
<li><p>Typ在Linux上使用源码的方式安装软件非常满分，使用yum可以简化安装的过程</p>
<h3 id="YUM的常用命令"><a href="#YUM的常用命令" class="headerlink" title="YUM的常用命令"></a><a href="#YUM的常用命令" title="YUM的常用命令"></a>YUM的常用命令</h3><p>安装httpd并确认安装<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum instll -y httpd</div></pre></td></tr></table></figure></p>
</li>
</ul>
<p>列出所有可用的package和package组</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum list</div></pre></td></tr></table></figure>

<p>清除所有缓冲数据</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum clean all</div></pre></td></tr></table></figure>

<p>列出一个包所有依赖的包</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum deplist httpd</div></pre></td></tr></table></figure>

<p>删除httpd</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum remove httpd</div></pre></td></tr></table></figure>

<h3 id="为什么要制作本地YUM源"><a href="#为什么要制作本地YUM源" class="headerlink" title="为什么要制作本地YUM源"></a><a href="#为什么要制作本地YUM源" title="为什么要制作本地YUM源"></a>为什么要制作本地YUM源</h3><p>YUM源虽然可以简化我们在Linux上安装软件的过程，但是生产环境通常无法上网，不能连接外网的YUM源，所以接就无法使用yum命令安装软件了。为了在内网中也可以使用yum安装相关的软件，就需要配置yum源。</p>
<h3 id="YUM源的原理"><a href="#YUM源的原理" class="headerlink" title="YUM源的原理"></a><a href="#YUM源的原理" title="YUM源的原理"></a>YUM源的原理</h3><p>YUM源其实就是一个保存了多个RPM包的服务器，可以通过http的方式来检索、下载并安装相关的RPM包<br><img src="http://123.57.181.198/images/linux/localyum1.jpg" alt="yum原理图"></p>
<h3 id="制作本地YUM源"><a href="#制作本地YUM源" class="headerlink" title="制作本地YUM源"></a><a href="#制作本地YUM源" title="制作本地YUM源"></a>制作本地YUM源</h3><ul>
<li>准备一台Linux服务器</li>
<li>准置好这台服务器的IP地址</li>
<li>上传CentOS-6.7-x86_64-bin-DVD1.iso(此镜像包含了丰富的rpm包)到服务器</li>
<li><p>将CentOS-6.7-x86_64-bin-DVD1.iso镜像挂载到某个目录</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ mkdir /var/iso</div><div class="line">$ mount -o loop CentOS-6.7-x86_64-bin-DVD1.iso /var/iso</div></pre></td></tr></table></figure>
</li>
<li><p>修改本机上的YUM源配置文件，将源指向自己备份原有的YUM源的配置文件</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> /etc/yum.repos.d/</div><div class="line">$ rename .repo .repo.bak *</div><div class="line">$ vi CentOS-Local.repo</div></pre></td></tr></table></figure><br><figure class="highlight ini"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="section">[base]</span></div><div class="line"><span class="attr">name</span>=CentOS-Local</div><div class="line"><span class="attr">baseurl</span>=file:///var/iso</div><div class="line"><span class="attr">gpgcheck</span>=<span class="number">1</span></div><div class="line"><span class="attr">gpgkey</span>=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<span class="number">6</span></div></pre></td></tr></table></figure>

</li>
</ul>
<p>添加上面内容保存退出</p>
<ul>
<li><p>清除YUM缓冲</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum clean all</div></pre></td></tr></table></figure>
</li>
<li><p>列出可用的YUM源</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum repolist</div></pre></td></tr></table></figure>
</li>
<li><p>安装相应的软件</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum install -y httpd</div></pre></td></tr></table></figure>
</li>
<li><p>开启httpd使用浏览器访问<a href="http://192.168.0.100:80o如果访问不通，检查防火墙是否开启了80端口或关闭防火墙）" target="_blank" rel="external">http://192.168.0.100:80o如果访问不通，检查防火墙是否开启了80端口或关闭防火墙）</a></p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ service httpd start</div></pre></td></tr></table></figure>
</li>
<li><p>将YUM源配置到httpd（Apache Server）中，其他的服务器即可通过网络访问这个内网中的YUM源了</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ cp -r /var/iso/ /var/www/html/CentOS-6.7</div></pre></td></tr></table></figure>
</li>
<li><p>取消先前挂载的镜像</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ umount /var/iso</div></pre></td></tr></table></figure>
</li>
<li><p>在浏览器中访问<a href="http://192.168.0.100/CentOS-6.7/" target="_blank" rel="external">http://192.168.0.100/CentOS-6.7/</a><br><img src="http://123.57.181.198/images/linux/localyum.jpg" alt="将yum源做成一个web服务"></p>
</li>
<li><p>让其他需要安装RPM包的服务器指向这个YUM源，准备一台新的服务器，备份或删除原有的YUM源配置文件</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> /etc/yum.repos.d/</div><div class="line">$ rename .repo .repo.bak *</div><div class="line">$ vi CentOS-Local.repo</div></pre></td></tr></table></figure><br><figure class="highlight ini"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="section">[base]</span></div><div class="line"><span class="attr">name</span>=CentOS-Local</div><div class="line"><span class="attr">baseurl</span>=http://<span class="number">192.168</span>.<span class="number">0.100</span>/CentOS-<span class="number">6.7</span>/</div><div class="line"><span class="attr">gpgcheck</span>=<span class="number">1</span></div><div class="line"><span class="attr">gpgkey</span>=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-<span class="number">6</span></div></pre></td></tr></table></figure>

</li>
</ul>
<p>添加上面内容保存退出</p>
<ul>
<li><p>在这台新的服务器上执行YUM的命令</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ yum clean all</div><div class="line">$ yum repolist</div></pre></td></tr></table></figure>
</li>
<li><p>安装相应的软件</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ yum install -y gcc</div></pre></td></tr></table></figure></li>
</ul>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/计算机/" rel="tag"># 计算机</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/11/22/儒学三纲八目/" rel="next" title="儒学三纲八目">
                <i class="fa fa-chevron-left"></i> 儒学三纲八目
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/11/22/nginx反向代理与负载均衡/" rel="prev" title="nginx反向代理与负载均衡">
                nginx反向代理与负载均衡 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="/uploads/avatar.jpg"
              alt="eregg" />
          
            <p class="site-author-name" itemprop="name">eregg</p>
            <p class="site-description motion-element" itemprop="description">青，取之于蓝，而青于蓝</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives/">
            
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">31</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/eregg" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>GitHub</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="mailto:ereggmail@163.com" target="_blank" title="E-Mail">
                  
                    <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#什么是YUM"><span class="nav-number">1.</span> <span class="nav-text">什么是YUM</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#YUM的作用"><span class="nav-number">2.</span> <span class="nav-text">YUM的作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#YUM的常用命令"><span class="nav-number">3.</span> <span class="nav-text">YUM的常用命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#为什么要制作本地YUM源"><span class="nav-number">4.</span> <span class="nav-text">为什么要制作本地YUM源</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#YUM源的原理"><span class="nav-number">5.</span> <span class="nav-text">YUM源的原理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#制作本地YUM源"><span class="nav-number">6.</span> <span class="nav-text">制作本地YUM源</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 &mdash; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">eregg</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动</div>

  <span class="post-meta-divider">|</span>

  <div class="theme-info">主题 &mdash; <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.2</div>


        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  

  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  








  





  

  

  

  

  

  

</body>
</html>
